/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.smn.dao;

import com.smn.domain.MyUser;
import com.smn.domain.Ticket;
import java.security.acl.Owner;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author akefeli
 */
@Stateless
public class TicketFacade extends AbstractFacade<Ticket> {

    @PersistenceContext(unitName = "sharemenowPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public TicketFacade() {
        super(Ticket.class);
    }

    public List<Ticket> getMyTickets(MyUser current) {
        try {
            Query cq = (Query) getEntityManager().createQuery("select t from Ticket t where t.referer = :owner");
            cq.setParameter("owner", current);
            return (List<Ticket>) cq.getResultList();
        } catch (Exception e) {
            e.toString();
            return null;
        }

    }
}
